/**
 * TestControl.java
 * 
 * Copyright (c) 2004-2020 UC Mobile Ltd.
 * F/4,Building B,Guangzhou Xinxigang,No.16 Keyun Rd,Guangzhou,China
 * All right reserved.
 * 
 * Created on 2012-10-29
 */
package com.uc.browser.main;

import java.io.IOException;
import java.io.InputStream;

import com.uc.browser.useragent.UserAgent;
import com.uc.browser.useragent.UserAgentFactory;

/**
 * <b>TestControl简介:</b>
 * <p>控制台的简单例子，输入一串User-Angent，X-UCBrowser-UA数据生成对应的对象模型，并输出数据结果</p>
 *
 * @author raorq
 * @version 1.0
 */
public class TestControl {

    /**
     * <p></p>
     *
     * @param args
     */
    public static void main(String[] args) {
        System.out.println("Pleas Input User-Agent：");
        InputStream is = System.in;
        int sLen  = -1;
        while(true){
            byte[] sb = new byte[2048];
            try {
                sLen = is.read(sb);
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            String text = new String(sb, 0, sLen - 2);
            if("exit".equals(text)){
                return;
            }else{
                 UserAgent ua = UserAgentFactory.createUserAgent(text);
                 System.err.println("UserAgent Parse Result: ");
                 System.out.println(ua.toString());
            }
        } 
    }

}